<?php 


// 发送HTTP头文件
header("Content-type: image/png");

// 创建画布
$src = imageCreateTrueColor(400,200); 

//设置颜色
$color = imageColorAllocate($src,255,255,255); 
// 填充颜色
imageFill($src,0,0,$color);


//设置颜色
$color = imageColorAllocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); 

// imagerectangle ($src, 30 , 30 ,80 ,80 , $color);

// imagefilledrectangle  ($src, 30 , 30 ,80 ,80 , $color);

// imageellipse ( $src , 200, 100 , 80 , 150,$color);

// imagefilledellipse ( $src , 200, 100 , 80 , 150,$color);

$ystart =10;
$yend = 10;

for ($i=0; $i <= 20; $i++) {
	$color = imageColorAllocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
	$xstart = 0;
	$ystart +=10;
	$xend = 400;
	$yend += 10; 
	imageline ($src,$xstart,$ystart,$xend,$yend, $color);
}

for ($i=0; $i <1000 ; $i++) { 
	$color = imageColorAllocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
	imagesetpixel ( $src, mt_rand(0,400), mt_rand(0,200),  $color );
}

$str = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";

$x = (400/4)*0.3;
for ($i=0; $i <4 ; $i++) { 
	$font = $str[mt_rand(0,strlen($str)-1)];

	$color = imageColorAllocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));

	imagettftext ( $src ,100, mt_rand(-30,30) ,$x, 150 , $color,"./plume.otf",$font);

	$x +=100;
}

 
$code = uniqid();
// 输出图像
imagepng($src); 

imageDestroy($src); 

// var_dump($src);











 ?>